package ch.nostromo.tiffanys.tests.libraries;

import ch.nostromo.tiffanys.game.GameController;
import ch.nostromo.tiffanys.game.GameControllerException;
import ch.nostromo.tiffanys.game.pgn.PGN;
import ch.nostromo.tiffanys.tests.TestBase;

public class TestPgn extends TestBase {

  public void testPgn() throws GameControllerException {
    String pgnInput = "";
    pgnInput += "[Site \"?\"]\n";
    pgnInput += "[Date \"2007.08.14\"]\n";
    pgnInput += "[Round \"-\"]\n";
    pgnInput += "[White \"Tiffanys Two\"]\n";
    pgnInput += "[Black \"Tiffanys Three\"]\n";
    pgnInput += "[Result \"*\"]\n";
    pgnInput += "\n";
    // pgnInput +=
    // "1.e4 d5 2.e5 Nd7 3.Nf3 c5 4.e6 fxe6 5.Nc3 d4 6.Bb5 dxc3 7.dxc3 Qb6 8.Qd3 a6 \n";
    // pgnInput +=
    // "9.Ba4 Qd6 10.Qe4 Qd5 11.Qxd5 exd5 12.Bf4 b5 13.Bb3 c4 14.Rd1 Ngf6 15.Bg5 cxb3 \n";
    // pgnInput +=
    // "16.cxb3 e6 17.Bxf6 Nxf6 18.Ke2 Bd6 19.c4 Bd7 20.cxd5 exd5 21.Rhe1 O-O-O \n";
    // pgnInput +=
    // "22.Rc1+ Kb7 23.Kd3 Rhe8 24.Nd4 Ng4 25.Re2 Rxe2 26.Kxe2 Re8+ 27.Kf1 Nxh2+ \n";
    // pgnInput +=
    // "28.Kg1 Re4 29.Rd1 Be5 30.Nc2 Kc6 31.g3 Nf3+ 32.Kg2 Bh3+ 33.Kxh3 Ng5+ 34.Kg2 \n";
    // pgnInput +=
    // "Bxb2 35.Ne3 d4 36.Nf5 g6 37.Nh4 Kd5 38.Nf3 Ne6 39.a4 Nc5 40.Rd2 Bc3 41.Rc2 \n";
    // pgnInput +=
    // "Nxb3 42.axb5 axb5 43.Ra2 h6 44.Kf1 g5 45.Kg2 g4 46.Nh2 d3 47.Ra3 Kc4 48.Ra7 \n";
    // pgnInput +=
    // "Nc5 49.Rc7 Kd5 50.Nf1 Bd4 51.Nh2 d2 52.Rh7 Nd3 53.Nxg4 Rxg4 54.f3 Rg6 55.Kh2 \n";
    // pgnInput +=
    // "Ne5 56.f4 d1=Q 57.Rd7+ Nxd7 58.g4 Qg1+ 59.Kh3 b4 60.f5 Rxg4 61.f6 Kc5 62.f7 *";

    pgnInput += "1.e4 d6 2.d4 g6 3.c4 Bg7 4.Nc3 Nc6 5.Be3 e5 6.d5 Nce7 7.c5 Nh6 8.f3 f5 9.cxd6 cxd6 \n";
    pgnInput += "10.Bb5+ Kf8 11.Qa4 f4 12.Bf2 Bf6 13.Nge2 Kg7 14.Rc1 a6 15.O-O g5 16.Rc2 Rb8 \n";
    pgnInput += "17.Bd3 Nf7 18.Rfc1 Qd7 19.Bb6 Qxa4 20.Nxa4 Bd7 21.Nec3 Rbc8 22.Ba5 Bxa4 23.Nxa4 Rxc2 \n";
    pgnInput += "24.Rxc2 Rc8 25.Nb6 Rxc2 26.Bxc2 h5 27.Ba4 g4 28.Bd7 gxf3 29.gxf3 Ng5 30.Kf2 Kf8 \n";
    pgnInput += "31.Nc4 Ng6 32.Bc8 Be7 33.Bxb7 Nh4 34.Nd2 Nh3+ 35.Kf1  1-0";

    GameController gc = PGN.importFirstPGN(pgnInput);

    String pgnOutput = gc.getPGN();

    logger.info(pgnInput);
    logger.info(pgnOutput);

    assertTrue(pgnInput.equals(pgnOutput));
  }
}
